<script setup lang="ts">
import SInfo from '@/components/common/info/SInfo.vue'
import { useInfo } from '@/composables/info-composable'
import type { ResultData } from '@/api/service'
import { invoiceInfoApi } from '@/api/invoice-api'
import type { InvoiceVo } from '@/type/Invoice'

const props = defineProps<{
  query: { id?: string }
  close: () => void
}>()

const { statement, infoLoading, infoData, validErrors } = useInfo<InvoiceVo>('InvoiceInfo', getData)

function getData() {
  if (props.query.id !== undefined) {
    infoLoading.value = true
    // 页面传递id, 调用接口查询数据回显
    invoiceInfoApi(props.query.id).then((response: ResultData<InvoiceVo>) => {
      infoData.value = response.data
      infoLoading.value = false
    })
  }
}

const methods = {}
</script>

<template>
  <s-info
    :data="infoData"
    :form-loading="infoLoading"
    :methods="methods"
    :statement="statement"
    :show-button="false"
  >
  </s-info>
</template>

<style scoped></style>